import time

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By

dr = webdriver.Chrome(service=Service('chromedriver.exe'))
dr.get('https://www.baidu.com')
dr.find_element(By.ID, 'kw').send_keys('selenium')
dr.find_element(By.ID, 'su').click()
time.sleep(2)
# 网页后退
dr.back()
time.sleep(2)
# 网页前进
dr.forward()
time.sleep(2)

